/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package htmlunit.code;

import htmlunit.mode.Link;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author TiTa
 */
public class thread_queue extends Thread{
    /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author TiTa
 */

    // queue_url queue=new queue_url();
//public queue_url qurl;
    Link l=new Link();
      private boolean paused;
    private boolean running;
queue_url qurl=new queue_url();
public thread_queue(){
  
}
int a;
  public  thread_queue(Link ll) {
    this.l=ll;
  
  }
    public  thread_queue(queue_url q_url) {
        this.qurl=q_url;
        //new Thread(this, "Producer").start();
   }
public  thread_queue(queue_url q_url,int a1) {
        this.qurl=q_url;
        //new Thread(this, "Producer").start();
        this.a=a1;
         paused = false;
        running = true;
        
   }
public void Stop() {
        running = false;
        if (paused)
            interrupt();
        try {
            join();
        } catch (InterruptedException ex) {
        }
    }
       public void Pause() {
        paused = true;
    }

    public void Resume() {      
        interrupt();
        paused = false;
    }
   
   @Override
    public void run(){while (running) {//running =true
            while (!paused){//pause=false
                try {
                    Thread.sleep(500);
   //  while(qurl.rong()==true){
      for(int i=0;i<a;i++){
          // while(true){
        String q =  qurl.lay();
    //  vision_v1 v1=new vision_v1();
     // v1.crawler_facebook(q);
   //  parse_page_facebook ppf=new parse_page_facebook(l);
     // ppf.parse_facebook_is_page_fbLongBlurb(q);
        //   System.out.print("chay");
      }
      //Pause();
      //Stop();
      
         } catch (InterruptedException e) {
                    paused = true;
                        } catch (Exception ex) {
                    Logger.getLogger(thread_queue.class.getName()).log(Level.SEVERE, null, ex);
                }
      }
              try {
            Thread.currentThread().sleep(100);
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
           
       }
  }
    // public static void main(String[] args){
   // thread_queue tq=new thread_queue();
    // 
    // qq.lay();
   //  tq.start();
   //  }


}
